import {
	DEPortalViewActionType,
	IDEPortalViewAbility,
	IDEPortalViewControllerParams,
	IDEPortalViewModel,
	IDEPortalViewStore,
	IParam,
	IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getViewClassNames,
	useViewAction,
	useViewBasic,
	useViewControllerParams,
	useViewProps,
} from '../use-view';

/**
 * 获取实体数据看板视图输入参数
 *
 * @export
 * @return {*}
 */
export function useDEPortalViewProps() {
	return {
		...useViewProps(),
		noViewCaption: {
			type: Boolean,
			default: true,
		},
	};
}

/**
 * 获取实体数据看板视图基础
 *
 * @export
 * @param {IDEPortalViewModel} model 实体数据看板视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function useDEPortalViewBasic(model: IDEPortalViewModel, props: IParam) {
	const getClassNames = (props: IParam) => {
		return getViewClassNames(model, props);
	};
	const getSearchFormSlotName = (props: IParam) => {
		const showTabPageExp = App.getProjectSetting().multiTabsSetting.show;
		let searchFormSlotName = 'viewHeaderTop';
		if (!showTabPageExp && props.openType == 'ROUTE') {
			searchFormSlotName = 'viewHeaderBottom';
		}
		return searchFormSlotName;
	};
	return {
		...useViewBasic(model, props),
		getClassNames,
		getSearchFormSlotName,
	};
}

/**
 * 实体数据看板视图行为
 *
 * @export
 */
export function useDEPortalViewAction(controller: any) {
	return {
		...useViewAction(controller),
	};
}

/**
 * 获取实体数据看板视图控制器输入参数
 *
 * @export
 * @param {IDEPortalViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<DEPortalViewActionType, IDEPortalViewAbility>>} evt
 * @return {*}  {IDEPortalViewControllerParams<DEPortalViewActionType, IDEPortalViewAbility>}
 */
export function useDEPortalViewControllerParams(
	model: IDEPortalViewModel,
	props: IParam,
	evt: QXEvent<IViewEvent<DEPortalViewActionType, IDEPortalViewAbility>>
): IDEPortalViewControllerParams<DEPortalViewActionType, IDEPortalViewAbility> {
	return {
		...useViewControllerParams<IDEPortalViewStore, IDEPortalViewModel>(
			model,
			props,
			evt
		),
	};
}
